home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
biz
/
dopus
/
HTTPlister.lha
/
HTTPlisterV1.8.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-01-04
|
19KB
|
797 lines
/* $VER: HTTPlister.rexx 1.8 1998
Copyright © 1998 Brian Scott
Email: bscott@odyssey.apana.org.au
*/
/* *** HTTPResume by Andrija Antonijevics IS REQUIRED. ***
This ARexx script reads and lists an aminet listing either the RECENT
file or another of the same format into a Dopus lister.
You get 3 columns, Name, Comment & Date giving you the instant sorting
that Dopus provides in any column by selecting either the 'Name',
'Comment' or 'Date' labels in the lister.
The aminet file's Dir, Size & Desc. go in the 'Comment' column.
Selecting the 'Comment' label in the lister gets all the aminet
directories sorted into groups.
Selecting the 'Date' label in the lister gets all the lines sorted in
the same order as they were in the file they came from. (The 'dates'
are meaningless - generated for sorting purposes only).
It is actually the 'time' part of the date field that gets incremented,
the dates remain constant.
o The most downloaded files from Aminet during the week have the date
22-Feb-88.
o The highest rated programs during the week have the date 30-Mar-98.
o The rest have the date 01-Jan-78.
By adding aminet direc/tories to the FilterOut string below,
you can prevent some from being listed in the lister.
Check it out as I've left a couple there as examples and you may
want to list them.
If you run this script from a Dopus menu etc. set the flag
Run asynchronously.
YOU WILL NEED TO CHANGE THE VALUE OF THESE VARIABLES:
----------------------------------------------------
o HTTPresume (HTTPresume with it's full path)
o PRXY (Your proxy:port) /* See the HTTPResume docs on setting PROXY */
o amiURL Your aminet URL (Should start with http://)
o and as mentioned the FilterOut string will need editing.
If you wish to use this without a proxy remove the PRXY variable line and
make sure that the aminet URL (amiURL variable below) you choose starts
with 'http://' and not 'ftp://'. (This comes from someone that doesn't
use a proxy. I use one so I can't test this).
And if you like you can free up the sound system below. For indicating
when the downloading has finished.
Note!
* This is strictly USE AT YOUR OWN RISK.
* This has only been tested with Directory Opus 5.661 Magellan and
* HTTPResume 1.3.
* The names listed in the lister are only pseudo-files and can't be
* treated as you would other file names in normal listers. Only apply
* the actions that I outline and it should all work OK.
*/
/***** Main Variables *********/
/* As many as you like, that you DON'T want in the lister. */
FilterOut = "comm/ambos comm/bbs comm/cnet" /* eg. */
HTTPresume = 'DATA:COMM/WEB/HTTPResume/HTTPResume'
PRXY = "HTTP://anonymous:you@whereever.you.are:8080"
/* Suit yourself for your aminet URL */
/* amiURL = "http://ftp.wustl.edu/pub/aminet/" */
/* amiURL = "wuarchive.wustl.edu/~aminet/dirs/aminet/" */
amiURL = "http://ftp.livewire.com.au/pub/aminet/"
DDir = "RAM:" /* Where the downloaded files will end up. */
/***** Sound System setup *********/
/* You'll need to free this up (remove the comment tags)
and give paths etc. for your player and sound file.
*/
/*
soundafter = 300 /* Only play a sound (to notify finish of downloading) */
/* if it takes longer than this many seconds to download. */
/* Find sound files at http://www.moviesounds.com/ */
fini_sound = "DATA:COMM/Sound/12-1234.wav"
soundplayer = "c:play16"
/* eg. of how it's run.. ADDRESS command soundplayer||" >nil: "||fini_sound */
*/
/***** It's All Action from here on.. (Tamper at your own peril.) *********/
parse arg listingfyl
ADDRESS 'DOPUS.1'
OPTIONS RESULTS
signal on syntax
LF = '0a'x
dopus version
If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
dopus request '"This script requires DOpus v5.5 or greater." OK'
EXIT
end
httpargs = sethttparg(DDir)
maxsgsz = 3000 /* Msg of day size to show in Req. Larger gets Read. */
HTTPlabel = "HTTPlister"
topdefault = "Aminet listing"
toploading = 'Loading list..'
Amotd = ""
HTTPToolBar = "GETAMINET.BUTTONS"
if ~show('L','rexxsupport.library') then
addlib('rexxsupport.library',0,-30,0)
if listingfyl = "" then listingfyl = slcd()
if listingfyl = "" then CALL tata('"You need to provide ONE aminet listing file."')
listingOK = chkfyl(listingfyl) /* Returns with the listing file still open. */
if ~listingOK then do
CALL close('r')
CALL tata(listingfyl||LF||'"Doesn''t contain an aminet listing."')
end
ln = chkln /* The first line that proved to be of aminet format. */
running = chkrunning() /* Check if HTTPlister is already running, if it is */
/* use the same lister to view an incoming list. */
if running > 0 then do
CALL loadrunning(running)
if Amotd ~= "" then CALL readAmotd() /* Message of the day. */
EXIT
end
lister new "1/11/690/425 "
ALH = result
lister set ALH TOOLBAR HTTPToolBar /* getaminet.buttons */
lister set ALH display name comment date
lister set ALH source
lister set ALH title toploading
lister set ALH label HTTPlabel
lister clear ALH
lister refresh ALH full
lister set ALH busy 1
CALL loadlist() /* Listing file gets closed here. */
topmsg = gettopmsg(listingfyl)
lister set ALH busy 0
lister set ALH title topmsg
lister refresh ALH full
handlername = HTTP||ALH
dopus addtrap '*' handlername /* Trap all dopus commands. */
dopus remtrap 'none' handlername /* UnSelect button uses 'none' */
if Amotd ~= "" then CALL readAmotd()
lister set ALH handler handlername
CALL openport(handlername)
do until event='inactive'
if waitpkt(handlername) then do
packet=getpkt(handlername)
if packet~='00000000'x then do
event=getarg(packet,0)
desti=getarg(packet,1)
namestr=getarg(packet,2)
user=getarg(packet,3)
pathstr=getarg(packet,4)
reqreturn=getarg(packet,5)
qualifier=getarg(packet,6)
CALL delay(10)
select
when (qualifier='shift') & (event='doubleclick') then
CALL readOPT()
when event='Parent' then
CALL downloadOPT()
when event='Assign' & (strip(reqreturn,'b') ~= "") then
DDir = reqreturn
when event='Root' then do
lister set ALH source
lister set ALH busy 1
CALL findstring()
lister set ALH busy 0
end
when (event='doubleclick') then CALL timedmsg("Shift-Select to read")
when (event='All') then do
CALL load()
if Amotd ~= "" then CALL readAmotd()
end
when (event='drop') then do
if words(namestr) = 1 then do
lister query user path
reqreturn = result||namestr
CALL load()
if Amotd ~= "" then CALL readAmotd()
end
else CALL givemsg('"You need to provide ONE aminet listing file."')
end
when (qualifier='shift') & (event='dropfrom') then do
lister query user busy
if ~result then do
if words(namestr) = 1 then do
DDir = reqreturn
Dhandle = user /* Adopt lister for downloading */
CALL readOPT()
end
else
CALL givemsg('"Sorry only ONE readme at a time."')
end
end
when (event='dropfrom') then do
lister query user busy
if ~result then do
DDir = reqreturn
Dhandle = user
lister set user dest
lister refresh user
do s = 1 to words(namestr) /* 'dropfrom' de-selected them. */
lister select ALH word(namestr,s) on
end
lister refresh ALH
CALL downloadOPT()
end
end
otherwise NOP
end
CALL reply(packet,0)
end
end
end
CALL closeport(handlername)
EXIT
readOPT:
lister set ALH busy 1
httpargs = sethttparg(DDir)
CALL gogetrm(namestr)
lister set ALH busy 0
if exists(DDir||refyl) then do
dopus read DDir||refyl
if event='dropfrom' then CALL showdownloads()
end
else
CALL givemsg(refyl||'" not downloaded!"')
RETURN
downloadOPT:
lister set ALH source
lister set ALH busy 1
httpargs = sethttparg(DDir)
gotem = gogetem()
lister set ALH busy 0
if gotem then CALL showdownloads()
RETURN
load:
listingOK = chkfyl(reqreturn) /* Returns with file still open. */
if ~listingOK then do
CALL close('r')
CALL givemsg(reqreturn||LF||'"Doesn''t contain an aminet listing."')
end
else do
lister set ALH source
ln = chkln
lister set ALH title toploading
lister refresh ALH full
lister set ALH busy 1
lister clear ALH
CALL loadlist() /* File gets closed here. */
topmsg = gettopmsg(reqreturn)
lister set ALH busy 0
lister set ALH title topmsg
lister refresh ALH full
end
RETURN
chkrunning:
ALH = 0
lister query all var handles
hcount = words(handles)
do h = 1 to hcount
hndl = word(handles,h)
lister query hndl toolbar /* query label doesn't want to work?! */
TB = upper(result)
if index(TB,HTTPToolBar) > 0 then ALH = hndl
end
RETURN ALH
loadrunning:
arg ALH
lister set ALH source
lister set ALH title toploading
lister set ALH busy 1
lister refresh ALH full
lister clear ALH
CALL loadlist() /* File gets closed here. */
topmsg = gettopmsg(listingfyl)
lister set ALH busy 0
lister set ALH title topmsg
lister refresh ALH full
RETURN
loadlist:
lynnum = 0
MDF = 0; HRP = 0
Amotd = ""
LF = '0a'x
do while ~EOF('r')
if ln ~= "" then do
if index(ln,"|") = 1 then do
MDF = 0; HRP = 0
do while index(ln,"|") = 1 & ~EOF('r')
select
when index(ln,"most downloaded files") > 0 then MDF = 1
when index(ln,"highest rated programs") > 0 then HRP = 1
otherwise NOP
end
ln = readln('r')
end
parse var ln +18 t1 +1 ap +10 t2 +1 .
if ~((t1||t2 == " ") & (index(ap,"/") >0)) & (MDF | HRP) then do
MDF = 0; HRP = 0
end
end
if EOF('r') then LEAVE
parse var ln +18 t1 +1 ap +10 t2 +1 .
if index(ln,"Message of the day:") > 0 then do
do while ~EOF('r') & ~((t1||t2 == " ") & (index(ap,"/") >0))
Amotd = Amotd||ln||LF
ln = readln('r')
parse var ln +18 t1 +1 ap +10 t2 +1 .
end
end
if EOF('r') then LEAVE
parse var ln aminame amidir amirest
if (index(FilterOut,amidir) = 0) & (t1||t2 == " ") & (index(ap,"/") >0) then do
lynnum = lynnum +1
select
when MDF then linedayt = lynnum +320025661
when HRP then linedayt = lynnum +638755261
otherwise linedayt = lynnum
end
entry.name = aminame
entry.comment = amidir||amirest
entry.date = linedayt
lister addstem ALH entry
end
end
ln = readln('r')
end
CALL close('r')
RETURN
gogetem:
lister query ALH numselfiles
totsel = result
gotsome = 0
numdwnldd = 0
if totsel ~> 0 then RETURN gotsome
lister query ALH selfiles stem fyl.
loadmsg = loadHTTPresume()
if loadmsg = "" then do
ADDRESS 'DOPUS.1'
do i = 0 to totsel -1
lister query ALH entry fyl.i stem fylinfo
parse var fylinfo.comment amipath rest
if totsel > 1 then
DLfsz.i = getasz(left(amipath||rest,16))
Uset.i = amiURL||amipath||"/"||fyl.i
end
tmp = time(reset) /* set elapsed time to 0.00 */
if totsel > 1 then do /* Bubble smallest to highest */
do ii=0 to totsel -1
do j=ii+1 to totsel -1
if DLfsz.ii > DLfsz.j then parse value Uset.ii Uset.j fyl.ii fyl.j DLfsz.ii DLfsz.j with Uset.j Uset.ii fyl.j fyl.ii DLfsz.j DLfsz.ii .
end
end
end
ADDRESS(Port)
do J=0 to totsel-1
SET OUTFILE DDir||fyl.J
SET URL Uset.J
START
Working=1
do while Working>0
QUERY FINISHED
Working=Result
CALL Delay(150) /* Pause 3 seconds */
end
if exists(DDir||fyl.J) then do
numdwnldd = numdwnldd +1
CALL deselect(fyl.J)
ADDRESS(Port)
end
end
QUIT
if (time(elapsed) >soundafter) & exists(soundplayer) & exists(fini_sound) then do
ADDRESS command soundplayer||" >nil: "||fini_sound
CALL delay(100)
end
else
CALL delay(150)
ADDRESS 'DOPUS.1'
lister query ALH numselfiles
numnotfound = result
if numnotfound > 0 then dopus request '"Number of files not found: "'||numnotfound' OK'
end
else
if index(loadmsg,"temporary file") = 0 then dopus request 'loadmsg'
if numdwnldd > 0 then gotsome = 1
RETURN gotsome
gogetrm:
parse arg rf
parse var rf nm "." .
refyl = nm||".readme"
loadmsg = loadHTTPresume()
if loadmsg = "" then do
lister query ALH entry rf stem fylinfo
parse var fylinfo.comment amipath .
Uset = amiURL||amipath||"/"||refyl
ADDRESS(Port)
SET OUTFILE DDir||refyl
SET URL Uset
START
Working=1
do while Working>0
QUERY FINISHED
Working=Result
CALL Delay(150) /* Pause 3 seconds */
end
QUIT
end
else
if index(loadmsg,"temporary file") = 0 then dopus request 'loadmsg'
RETURN
loadHTTPresume:
succ = ""
TmpFile='T:HTTPResume.tmp.'||random(,,time('s'))||'.'random(,,)
ADDRESS COMMAND 'Run '||HTTPresume||httpargs||TmpFile
CALL Delay(150) /* Wait 3 seconds for HTTPResume to start */
if ~OPEN(PortFile, TmpFile, 'R') then
succ = '"Couldn''t open temporary file!"'
else do
Port=READLN(PortFile)
CLOSE(PortFile)
CALL DELETE(TmpFile)
IF Port='***' then succ = '"HTTPResume couldn''t open its ARexx port!"'
end
RETURN succ
deselect: procedure expose ALH
parse arg fyl
ADDRESS 'DOPUS.1'
lister select ALH fyl off /* De-select that file. */
lister refresh ALH
RETURN
showdownloads:
lister query all
alltrs = result
stillopen = index(alltrs,Dhandle)
select
when stillopen > 0 then do
lister set Dhandle dest
lister read Dhandle DDir
end
when stillopen = 0 then do
lister new "1/200/350/200 " DDir
Dhandle = result
lister wait Dhandle
lister set Dhandle dest
end
otherwise NOP
end
RETURN
slcd:
rcnt = ""
lister query source; if RC > 0 then RETURN rcnt
src = result
lister query src numselfiles
totsel = result
if (totsel = 0) | (totsel > 1) then RETURN rcnt
lister query src path
srcpth = result
lister query src selfiles stem fyl.
amilist = fyl.0
rcnt = srcpth||amilist
lister select src amilist off /* De-select that file. */
lister refresh src
RETURN rcnt
chkfyl: procedure expose chkln recdayt
parse arg amilisting
rcntOK = 1
lncntr = 0
maxcnt = 100
recdayt = ""
if ~open('r',amilisting,'r') then CALL tata('"Can''t open "'||amilisting, 20)
chkln = readln('r')
parse var chkln +18 t1 +1 ap +10 t2 +1 .
do while ~EOF('r') & ~((t1||t2 == " ") & (index(ap,"/") >0)) & ~(lncntr > maxcnt)
lncntr = lncntr +1
chkln = readln('r')
if index(chkln,"Date:") = 1 then recdayt = getrecdayt(chkln)
parse var chkln +18 t1 +1 ap +10 t2 +1 .
end
if EOF('r') | (lncntr > maxcnt) then do
CALL close('r')
rcntOK = 0
end
RETURN rcntOK
getrecdayt:
parse arg rdl
rcd = ""
parse var rdl "Date:" . ", " dayt +11 rest
if index("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",word(dayt,2)) > 0 then rcd = dayt
RETURN rcd
findstring: procedure expose ALH srchstr
oldstr = ""
if (srchstr ~= "SRCHSTR") & (srchstr ~= "RESULT") then oldstr = srchstr
dopus getstring '"Non-case sensitive search. Don''t use wild cards." "'||oldstr||'" Okay|Cancel'
srchstr = result
butt = DOPUSRC
Usrchstr = upper(srchstr)
if (srchstr="RESULT" & butt<1) | (butt=1 & srchstr="RESULT" ) then RETURN
lister query ALH files stem filename.
lister query ALH numfiles
filecount = result
lister clear ALH abort
lister set ALH newprogress abort bar name title
lister set ALH newprogress title "Searching both columns for "||srchstr
lister set ALH newprogress bar numsel 0
do i = 0 to filecount-1
lister set ALH newprogress name filename.i
lister set ALH newprogress bar filecount i
lister query ALH entry filename.i stem fileinfo.
if index(upper(filename.i||fileinfo.comment),Usrchstr) > 0 then lister select ALH filename.i 1
lister query ALH abort
if result = 1 then do
lister set ALH newprogress off
lister refresh ALH full
RETURN
end
end
lister set ALH newprogress off
lister refresh ALH full
RETURN
gettopmsg:
parse arg lstfyl
tfnm = fylname(lstfyl)
tmsg = tfnm||" "||recdayt
if datatype(tfnm,'n') then tmsg = topdefault||" "||recdayt
RETURN tmsg
fylname:
parse arg fdir
slpos = lastpos('/',fdir)
parse var fdir ":"fn
if slpos > 0 then fn = substr(fdir,slpos+1)
RETURN fn
getasz: procedure
arg afsz
fsz = 0
parse var afsz nm sz .
kpos = index(sz,'K')
mpos = index(sz,'M')
select
when kpos > 0 then fsz=left(sz,kpos-1)
when mpos > 0 then fsz=left(sz,mpos-1)*1000
otherwise NOP
end
RETURN fsz
readAmotd:
if length(Amotd) < maxsgsz then
CALL givemsg('"'||Amotd||'"')
else
CALL readmsg(Amotd)
RETURN
sethttparg:
parse arg dwldir
if PRXY = "PRXY" | PRXY = "" then
hargs = ' OVERWRITE SD='||dwldir||' DEBUG='||dwldir||'HTTPdebug.log WINWIDTH=450 GUI NOERRREQ RXPORTFILE='
else
hargs = ' OVERWRITE PROXY='||PRXY||' SD='||dwldir||' DEBUG='||dwldir||'HTTPdebug.log WINWIDTH=450 GUI NOERRREQ RXPORTFILE='
RETURN hargs
readmsg: procedure
parse arg msg
CALL open('w',"T:temp_msg",'w')
CALL writeln('w',msg)
CALL close('w')
dopus read "T:temp_msg"
RETURN
timedmsg:
ADDRESS 'DOPUS.1'
parse arg msg
lister set ALH title msg
lister refresh ALH full
CALL delay(250)
lister set ALH title topdefault
lister refresh ALH full
RETURN
givemsg:
ADDRESS 'DOPUS.1'
parse arg msg
dopus request ''msg' OK'
RETURN
tata:
ADDRESS 'DOPUS.1'
parse arg msg
dopus request ''msg' OK'
EXIT
syntax:
LF = '0a'x
ADDRESS 'DOPUS.1'
errmsg = '"ABORTING!"'||LF||'"Please report this error:"'||LF||'"Syntax Error "'||rc||'" , "'||"'"||errortext(rc)||"'"||'" in line "'||sigl||'"."'
lister set ALH busy 0
dopus request ''errmsg' OK'
lister query ALH handler
if result = handlername then CALL closeport(handlername)
lister close ALH
EXIT